//
//  ThirdViewController.m
//  UIhomework_14
//
//  Created by dllo on 15/12/31.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "ThirdViewController.h"
#import "cinemaModel.h"
#import "CinemaTableViewCell.h"
@interface ThirdViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, retain) UITableView *tableview;
@property (nonatomic, retain) NSMutableArray *arr;
@property (nonatomic, retain) NSMutableArray *arrModel;
@end

@implementation ThirdViewController

-(void)dealloc{
    [_tableview release];
    [_arr release];
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.title = @"影院";
    self.tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 64) style:UITableViewStylePlain];
    [self.view addSubview:_tableview];
    _tableview.delegate = self;
    _tableview.dataSource = self;
    [_tableview registerClass:[CinemaTableViewCell class] forCellReuseIdentifier:@"cell"];
    [_tableview release];
    [self dataHandle];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//数据处理
- (void)dataHandle{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"cinema" ofType:@"plist"];
    self.arr = [NSMutableArray arrayWithContentsOfFile:path];
    //NSLog(@"%@", _arr);
    self.arrModel = [NSMutableArray array];
    for (NSDictionary *dic in _arr) {
        cinemaModel *model = [[cinemaModel alloc] init];
        [model setValuesForKeysWithDictionary:dic];
        [_arrModel addObject:model];
    }
    //NSLog(@"%@", _arrModel);
    
}

//协议部分
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _arrModel.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 250;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CinemaTableViewCell *cell = [[[CinemaTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"] autorelease];
    cell.imgView.image = [UIImage imageNamed:@"bg_eventlistcell.png"];
    cinemaModel *model = _arrModel[indexPath.row];
    cell.label1.text = model.cinemaName;
    cell.label2.text = model.address;
    cell.label3.text = model.telephone;
    return cell;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
